package com.xzy.service;

import com.xzy.mapper.TopicVoteMapper;
import com.xzy.mapper.VoteUserMapper;
import com.xzy.pojo.TopicVote;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TopicVoteServiceImpl implements TopicVoteService{
    @Autowired
    TopicVoteMapper topicVoteMapper;
    @Autowired
    VoteUserMapper voteUserMapper;
    @Override
    public List<TopicVote> selectTopicVotePage(int begin, int size) {
        return this.topicVoteMapper.selectTopicVotePage(begin, size);
    }

    @Override
    public int TopicVoteYes(Map<String, Object> map) {
        int res=this.topicVoteMapper.TopicVoteYes(map);
        if(res==1) {
            this.voteUserMapper.updateVoteTopicId(map);
        }
        return res;
    }

    @Override
    public int TopicVoteNo(Map<String, Object> map) {
        int res=this.topicVoteMapper.TopicVoteNo(map);
        if(res==1) {
            this.voteUserMapper.updateVoteTopicId(map);
        }
        return res;
    }

    @Override
    public int TopicVoteNoKnow(Map<String, Object> map) {
        int res=this.topicVoteMapper.TopicVoteNoKnow(map);
        if(res==1) {
            this.voteUserMapper.updateVoteTopicId(map);
        }
        return res;
    }

    @Override
    public int InsertTopic(String topicName, String topicAuthor) {
        return this.topicVoteMapper.InsertTopic(topicName, topicAuthor);
    }


}
